#ifndef GAMEPLAY_H
#define GAMEPLAY_H

#include <QWidget>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsPixmapItem>
#include <QPixmap>
#include<QVBoxLayout>
#include<QTimer>


class GamePlay : public QWidget {
    Q_OBJECT

public:
    explicit GamePlay(QWidget *parent = nullptr);
    ~GamePlay();
    void keyPressEvent(QKeyEvent *k);
    void mousePressEvent(QMouseEvent *m);
    QTimer *fallTimer;
    void FallToGround();
    int currentWidth = 600;
    int currentHeight = 600;
    const int minWidth = 300;
    const int minHeight = 300;
    QTimer *sizeChangeTimer;

private:
    QGraphicsScene *scene;
    QGraphicsView *view;
    QGraphicsPixmapItem *player;
    QPixmap playerPixmap;
    QRect boundary; // 场景边界，可以在需要时计算

    void adjustWindowSize();


};

#endif // GAMEPLAY_H
